const express=require("express");

const app=express();

const jwt =require("jsonwebtoken")

app.use(express.static("./count"))

app.get("/login",(req,res)=>{
    const token=jwt.sign({name:"天明",password:123},"周杰伦牛皮",(err,token)=>{
        if (err) return res.send({err: 1, msg: '登录失败'})
        res.send({err: 0, msg: token})
    })
})

app.get("/api/ui",(req,res)=>{
   var token =req.query.token
   jwt.verify(token, '周杰伦牛皮', (error, decoded) => {
    if (error) {
      console.log(error.message)
      return
    }
    res.send(decoded);
  })
})

app.listen(3003,()=>{
    console.log("http://localhost:3003")
})